/***
 * 求解两幅图片之间的单应矩阵
 ***/

#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace std;
using namespace cv;

int main(int argc, char **argv) {

    Mat image1=imread("../123.jpg",IMREAD_ANYCOLOR);
    Mat image2=imread("../234.jpg",IMREAD_ANYCOLOR);
    //assert(image1.data!=nullptr && image2.data!=nullptr);
    
    std::vector<KeyPoint> keypoints_1, keypoints_2;
    Mat descriptors_1, descriptors_2;
    Ptr<FeatureDetector> detector=ORB::create();
    Ptr<DescriptorExtractor> descriptor=ORB::create();
    Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce-Hamming");
    
    detector->detect(image1, keypoints_1);
    detector->detect(image2, keypoints_2);
    
    descriptor->compute(image1, keypoints_1, descriptors_1);
    descriptor->compute(image2, keypoints_2, descriptors_2);
    
    vector<DMatch> matches;
    matcher->match(descriptors_1, descriptors_2, matches);
    cout<<matches.size()<<endl;
    
    return 0;
}
